﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UserInterface.HelperForms
{
    public partial class EditCategory : Form
    {
        public int Category { get; set; }

        public EditCategory()
        {
            InitializeComponent();
        }

        private void SelectLogoButton_Click(object sender, EventArgs e)
        {
            OpenFile.ShowDialog(this);

            LogoImage.Image = Image.FromFile(OpenFile.FileName);

        }

        private void CancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void SaveButton_Click(object sender, EventArgs e)
        {
            OneSystems.BusinessLogic.DebtLogic.SaveCategory(Category, NameTextbox.Text, DescriptionTextBox.Text, (System.Drawing.Image)LogoImage.Image);
            this.Close();
        }

        private void EditCategory_Load(object sender, EventArgs e)
        {
            if (Category != 0)
            {
                OneSystems.Data.Entities.Category category = OneSystems.BusinessLogic.DebtLogic.GetCategory(Category);
                NameTextbox.Text = category.Name;
                DescriptionTextBox.Text = category.Description;
                LogoImage.Image = category.Logo;
            }
        }
    }
}
